<template>


    <table class="table table-bordered">

        <thead>

            <tr>
                <th style="background-color: aqua;">会员等级编号</th>
                <th style="background-color: aqua;">会员等级名称</th>
                <th style="background-color: aqua;">会员等级状态</th>
                <th style="background-color: aqua;">最大成长值</th>
                <th style="background-color: aqua;">最小成长值</th>
                <th style="background-color: aqua;">操作</th>
            </tr>



        </thead>

        <tbody v-for="item in list ">
            <tr>
                <th>{{ item.Rank_Id }}</th>
                <th>{{ item.Rank_Name }}</th>
                <th v-show="item.Rank_State == true" style="color:green ;">启用</th>
                <th v-show="item.Rank_State == false" style="color:red ;">禁用</th>
                <th>{{ item.Rank_MaxPoint }}</th>
                <th>{{ item.Rank_MinPoint }}</th>
                <th><a href="#" @click="Xg(item.Rank_Id)" class="btn btn-success">修改</a>

                    <a href="#" v-show="item.Rank_State == true" class="btn btn-success"
                        @click="CXT(item.Rank_Id, 0)">禁用</a>
                    <a href="#" v-show="item.Rank_State == false" class="btn btn-success"
                        @click="CXT(item.Rank_Id, 1)">启用</a>


                </th>
            </tr>



        </tbody>



    </table>



</template>


<script setup lang="ts">


import { onMounted, ref } from 'vue';

import { useRouter, createRouter } from 'vue-router'
import axios from 'axios';

const router = useRouter();

onMounted(() => {  //钩子函数


    RankSh();
})

const list = ref([{

    Rank_Id: 0,
    Rank_Name: "",
    Rank_State: true,
    Rank_MaxPoint: 0,
    Rank_MinPoint: 0
}]



);


const RankSh = () => {  //显示



    axios.get('https://localhost:7035/api/Rank/ShowRank')

        .then(res => {
            list.value = res.data


        })

        .catch(x => {


            console.log(x);

        })



};


const CXT =(Rank_Id:number ,Rank_Code:number)=>{

        axios.put('https://localhost:7035/api/Rank/UpStart',{parmars:{

            Rankid:Rank_Id,
            RankCode:Rank_Code,



        }}) .then(res=>{

            if(res.data>0)
        {
            alert('修改成功')
        }
        else
        {
            alert('修改失败')
        }

        })
        .catch(erroe=>{
            console.log(erroe)
        })


}

const Xg = (Rank_Id: number) => {


    router.push({
        name: "Rank_Xg",
        params: {
            Rid: Rank_Id,
        }

    })


}





</script>
